import { request } from 'umi';
import { api } from '@/services/config';

/**
 * 查询用户
 * @param params 
 */
export async function getUsers(params: any) {
  return request(api.system.user, {
    method: 'GET',
    params,
  });
}

/**
 * restful风格，增删改
 * @param params 
 */
export async function handleUser(params: any) {
  const { method, ...data } = params;
  return request(api.system.user, {
    method,
    data,
  });
}

/**
 * 重置密码
 * @param params 
 * @returns 
 */
export async function resetPassword(params: any) {
  return request(api.system.resetPwd, {
    method: 'POST',
    params,
  });
}

/**
 * 修改密码
 * @param params 
 * @returns 
 */
 export async function updatePassword(params: any) {
  return request(api.system.updatePwd, {
    method: 'POST',
    params,
  });
}

/**
 * 查询角色
 * @param params 
 */
export async function getRoles(params: any) {
    return request(api.system.role, {
      method: 'GET',
      params,
    });
  }

/**
 * role 的增删改
 */
export async function roles(params: any) {
    const { method, ...data } = params;
    return request(api.system.role, {
      method,
      data,
    });
  }
  

  /**
 * 权限的增删改查
 * @param {*} params
 */
export async function permissions(params: any) {
  const { method, ...data } = params;
  return request(api.system.permissions, {
    method,
    data,
  });
}

export async function sortPermission(params: any) {
  return request(api.system.sortPermission, {
    method: 'POST',
    data: params,
  });
}

/**
 * 查询操作日志
 * @param params 
 */
 export async function listLogs(params: any) {
  return request(api.system.listLogs, {
    method: 'GET',
    params,
  });
}